﻿namespace MDXStudio.Utils
{
    using System;
    using System.Collections.Generic;
    using System.Drawing;
    using System.Windows.Forms;

    internal static class UIUtil
    {
        public static void AddBWClones(ImageList pImageList)
        {
            Dictionary<string, Image> dictionary = new Dictionary<string, Image>();
            for (int i = 0; i < pImageList.Images.Count; i++)
            {
                Image image = pImageList.Images[i];
                string str = pImageList.Images.Keys[i];
                Bitmap bitmap = (Bitmap) image.Clone();
                for (int j = 0; j < bitmap.Width; j++)
                {
                    for (int k = 0; k < bitmap.Height; k++)
                    {
                        Color pixel = bitmap.GetPixel(j, k);
                        HSBColor color2 = new HSBColor(pixel);
                        Color color = HSBColor.ShiftSaturation(pixel, -color2.S);
                        bitmap.SetPixel(j, k, color);
                    }
                }
                dictionary.Add(str + "_BW", bitmap);
            }
            foreach (KeyValuePair<string, Image> pair in dictionary)
            {
                pImageList.Images.Add(pair.Key, pair.Value);
            }
        }

        public static void MessageError(IWin32Window pOwner, Exception pExc)
        {
        }

        public static void RemoveList<T>(IList<T> pList0, IList<T> pList1)
        {
            for (int i = pList0.Count - 1; i >= 0; i--)
            {
                foreach (T local in pList1)
                {
                    if (((IComparable<T>) pList0[i]).CompareTo(local) == 0)
                    {
                        pList0.RemoveAt(i);
                        break;
                    }
                }
            }
        }
    }
}

